package com.yueyang.sojourn.server.service.sojourn.order.inventory;

import com.yueyang.sojourn.server.model.po.SojournOrderInventory;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * @author yemingxing
 * @summary
 * @Copyright (c) 2020, Yueyang Group All Rights Reserved.
 * @since 2020-04-05 12:31
 */
@Service
public class SojournOrderInventoryService {

    @Resource
    private SojournOrderInventoryMapper sojournOrderInventoryMapper;


    public int insert(SojournOrderInventory record) {
        return sojournOrderInventoryMapper.insert(record);
    }


    public SojournOrderInventory selectByPrimaryKey(Integer id) {
        return sojournOrderInventoryMapper.selectByPrimaryKey(id);
    }


    public int updateByPrimaryKeySelective(SojournOrderInventory record) {
        return sojournOrderInventoryMapper.updateByPrimaryKeySelective(record);
    }

    public int batchInsert(List<SojournOrderInventory> list) {
        return sojournOrderInventoryMapper.batchInsert(list);
    }

    public List<SojournOrderInventory> selectByMerchIdAndEffectDate(long merchId, Date effectDateStart, Date effectDateEnd) {
        Assert.notNull(effectDateStart, "effectDateStart 不能为空");
        Assert.notNull(effectDateEnd, "effectDateEnd 不能为空");
        return sojournOrderInventoryMapper.selectByMerchIdAndEffectDate(merchId, effectDateStart, effectDateEnd);
    }

    public List<SojournOrderInventory> selectByOrderSn(String orderSn) {
        Assert.hasLength(orderSn, "orderSn 不能为空");
        return sojournOrderInventoryMapper.selectByOrderSn(orderSn);
    }
}
